import CommonAction from "../../../../../actions/common";
import {COMMON} from "../../../../../unit/util";

const rotateIcon = 'rotateIcon';
export default class HeaderAction extends CommonAction {
    constructor(comp) {
        super();
        this.comp = comp;
    }

    // 初始化
    didMount = () => {
        // 获取人数统计
    };

    // 卸载
    willUnMount = () => {

    };
    backToList = ()=> {
        let {dispatch,staffCom} = this.comp.props;
        let page = COMMON.pageMain;
        let formSub = false;
        if(staffCom.page === COMMON.pageSubdetail){
            page = staffCom.advObj.lastPage;
            formSub = true
        }
        dispatch({
            type:'staffCom/update',
            payload:{
                page,
                advObj:{},
                mainDate:'',
                formSub
            }
        })
    };

    clickExport = ()=>{
        console.log('export');
        this.comp.props.clickExport();
    };

    clickAdv = () => {
        let flag = this.comp.state.rotateAdvIcon === rotateIcon;
        this.comp.setState({
            rotateAdvIcon: flag ? null : rotateIcon
        });
        this.comp.props.updateState({
            showAdv: !flag
        });
    };

    clickShowMore = () => {
        let flag = !this.comp.state.showDropList;
        this.comp.setState({
            showDropList: flag,
            rotateMoreIcon: flag ? rotateIcon : null
        })
    };

    jump = async (key) => {
        let {dispatch} = this.comp.props;
        await new Promise(resolve => {
            this.comp.setState({
                showDropList: false,
                rotateMoreIcon: null
            }, resolve);
        });
        dispatch({
            type: 'staffCom/update',
            payload: {
                page: key
            }
        })
    }
}